<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>

<script type="text/javascript">
	$(function() {
		$.metadata.setType("attr", "validate");
		$("#search_friend_email_form").validate({
			submitHandler : function() {
				searchFriendEmail();
			}
		});
		$("#search_friend_doorplate_form").validate({
			submitHandler : function() {
				searchFriendDoorplate();
			}
		});
	});
	
	function searchFriendEmail() {
		var email = $("#email").val();
		if (IsNull(email)) {
			$("#email_error").show();
		} else {
			$("#email_error").hide();
			$("#searh_friend").load("searchFriend.htm?email=" + email);
		}
	}
	
	function searchFriendDoorplate() {
		var doorplate = $("#doorplate").val();
		if (IsNull(doorplate)) {
			$("#doorplate_error").show();
		} else {
			$("#doorplate_error").hide();
			$("#searh_friend").load("searchFriend.htm?doorplate=" + doorplate);
		}
	}
	
	//根据标签查找好友
	function searchFriendTag(){
		var tag = $("#search_tag").val();
		if(tag==""){
			$("#error_search_tag").html("请填写标签");
			return null;
		}else{
			$("#searh_friend").load("searchFriend.htm",{tag:tag});
		}
	}
	
	function searchFriendXX() {
		var inputCount = 0;
		var fnickName = $("#nickname").val();
		if (!IsNull(fnickName)) {
			inputCount += 1;
		}
		var username = $("#username").val();
		if (!IsNull(username)) {
			inputCount += 1;
		}
		var sex = $("#sex").val();
		if (!IsNull(sex)) {
			inputCount += 1;
		}
		var birthday = "";
		if (!IsNull($("#year").val()) && !IsNull($("#month").val())
				&& !IsNull($("#month").val())) {
			birthday = $("#year").val() + '-' + $("#month").val() + '-'
					+ $("#day").val();
			inputCount += 1;
		}
		var province = $("#province").val();
		var city = $("#city").val();
		var district = $("#district").val();

		if (!IsNull($("#province").val()) || !IsNull($("#city").val())
				|| !IsNull($("#district").val())) {
			inputCount += 1;
		}
		var birthPro = $("#birthPro").val();
		var birthCity = $("#birthCity").val();
		var birthDic = $("#birthDic").val();

		if (!IsNull($("#birthPro").val()) || !IsNull($("#birthCity").val())
				|| !IsNull($("#birthDic").val())) {
			inputCount += 1;
		}
		var babyName = $("#babyName").val();
		if (!IsNull(babyName)) {
			inputCount += 1;
		}

		if (inputCount < 2) {
			$("#error_list_two").show();
			return;
		} else {
			$("#error_list_two").hide();
		}

		$("#searh_friend").load("searchFriend.htm", {
			fnickName : fnickName,
			username : username,
			sex : sex,
			birthday : birthday,
			babyName : babyName,
			province : province,
			city : city,
			district : district,
			birthPro : birthPro,
			birthCity : birthCity,
			birthDic : birthDic
		});

	}

	function searchFriendCondition(type) {
		$("#searh_friend").load("searchFriendCondition.htm", function() {
			setTab('newNews', type, 2);
		});

	}
</script>

<div class="h_main2">
	<div class="h_data">
		<h2>邻居查找</h2>
		<div class="h_newNews">
			<ul>
				<li id="newNews1" onclick="searchFriendCondition('1');"
					class="h_newNewsHover"><a>精确查找</a></li>
				<li id="newNews2" onclick="searchFriendCondition('2');"><a>按条件查找</a>
				</li>
				<!--  
					<span><a href="#">邀请邻居</a> </span>
					-->
				<div class="clear"></div>
			</ul>
			<div class="clear"></div>
		</div>
		<div id="searh_friend">
			<div class="h_newNews_box">
				<div class="h_newNews_text" id="con_newNews_1"
					style="display: block;">
					<div class="find_box">
						<table>
							<tr>
								<td class="PI_text">邮箱：</td>
								<td><input class="h_find_comInput" type="text" id="email"
									name="email" /> <label id="email_error" for="email"
									style="display: none;" class="error">请填写邮箱</label></td>
								<td>
									<div class="h_button ml10" onclick="searchFriendEmail();">
										<strong>查 找</strong>
									</div></td>

							</tr>
							<tr>
								<td class="PI_text">门牌号：</td>
								<td><input class="h_find_comInput" type="text"
									id="doorplate" name="doorplate" /> <label id="doorplate_error"
									for="doorplate" style="display: none;" class="error">请填写门牌号</label>
								</td>
								<td>
									<div class="h_button ml10" onclick="searchFriendDoorplate();">
										<strong>查 找</strong>
									</div></td>
							</tr>
							<tr>
								<td class="PI_text">标签：</td>
								<td><input class="h_find_comInput" type="text"
									id="search_tag" name="search_tag" />
									<div style="color: red; display: inline;" id="error_search_tag"></div>
								</td>
								<td>
									<div class="h_button ml10" onclick="searchFriendTag();">
										<strong>查 找</strong>
									</div></td>
							</tr>
						</table>
					</div>
				</div>
				<div class="h_newNews_text" id="con_newNews_2">
					<div class="find_box">
						<table>
							<tr>
								<td class="PI_text">家昵称：</td>
								<td><input class="h_find_comInput" type="text"
									id="nickname" /></td>
							</tr>
							<tr>
								<td class="PI_text">户主名：</td>
								<td><input class="h_find_comInput" type="text"
									id="hostname" /></td>
							</tr>
							<tr>
								<td class="PI_text">性别：</td>
								<td><select class="h_find_comInput" id="sex">
										<option value="">请选择</option>
										<option value="M">男</option>
										<option value="F">女</option>
								</select></td>
							</tr>
							<tr>
								<td class="PI_text">生日：</td>
								<td id="searchBirthday"><select id="year"></select> <select
									id="month"></select> <select id="day"></select> <script
										type="text/javascript">
										yearMonthDay($("#searchBirthday"));
									</script></td>

							</tr>
							<tr>
								<td class="PI_text">现居地：</td>
								<td><input class="h_find_comInput" type="text" /></td>
							</tr>
							<tr>
								<td class="PI_text">家乡：</td>
								<td><input class="h_find_comInput" type="text" /></td>
							</tr>
							<tr>
								<td class="PI_text">宝宝姓名：</td>
								<td><input class="h_find_comInput" type="text"
									id="babyName" /></td>
							</tr>
							<tr>
								<td></td>
								<td>
									<div class="h_button ml10" onclick="searchFriendXX();">
										<strong>查 找</strong>
									</div></td>
							</tr>
						</table>
					</div>
				</div>

			</div>
		</div>

	</div>
</div>
